/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.eurotrader.validadores;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

/**
 *
 * @author PROG01
 */
public class ValidadorData implements Validator {

    @Override
    public void validate(FacesContext context, UIComponent validate, Object value) throws ValidatorException {
        try{
            System.out.println("value " + value);
            Date data = (Date) value;
            Calendar data1 = Calendar.getInstance();
            data1.setTime(data);
        }catch(Exception e){
            ((UIInput) validate).setValid(false);
            FacesMessage msg = new FacesMessage("Data Inválida");
            context.addMessage(validate.getClientId(context), msg);
        }
    }
}
